package user;

import java.util.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import connection.ConnectionOracleOR;


public class User {

	
	public ArrayList<String> getUser( String username ) throws Exception{
		
		ArrayList<String> result = new ArrayList<String>();
		
		try{
			
			ConnectionOracleOR oracleBruno 	= 	new ConnectionOracleOR( );
			Connection conexao 				= 	oracleBruno.newConnection( );			
			
			Statement statement 			= 	conexao.createStatement();
	        ResultSet rs 					= 	null;	        
	        String 	query					=	"select * from TP_USUARIO " +
	        		"							where VNOME='"+username+"' ";
            
	        rs = statement.executeQuery( query );
	        
	        if (rs.next()){
	        	
	        	//if(rs.getInt("existe")>0)
	        	//	result=true;     
	        	
	        }
	        	    
	        
	        rs.close();
	        statement.close();                
                
		}catch( Exception e){
			
			throw new Exception("erro: "+e.getMessage());
		}


		return result;
	}


	public boolean getLogin( String username, String password ) throws Exception{
		
		Boolean result=false;
		
		try{
			
			ConnectionOracleOR oracleBruno 	= 	new ConnectionOracleOR( );
			Connection conexao 				= 	oracleBruno.newConnection( );			
			
			Statement statement 			= 	conexao.createStatement();
	        ResultSet rs 					= 	null;	        
	        String 	query					=	"select count(*) existe from tb_administrador where VLOGIN='"+username+"' and VSENHA='"+password+"'";
            
	        rs = statement.executeQuery( query );
	        
	        if (rs.next())
	        	if(rs.getInt("existe")>0)
	        		result=true;         
	        
	        rs.close();
	        statement.close();   
	        conexao.close();
                
		}catch( Exception e){
			
			throw new Exception("erro: "+e.getMessage());
		}


		return result;
	}
}
